#!/bin/bash

echo "正在启动电子礼金SaaS系统..."
echo

# 检查Node.js是否安装
if ! command -v node &> /dev/null; then
    echo "错误: 未检测到Node.js，请先安装Node.js"
    echo "下载地址: https://nodejs.org/"
    exit 1
fi

# 检查npm是否安装
if ! command -v npm &> /dev/null; then
    echo "错误: 未检测到npm，请先安装npm"
    exit 1
fi

# 检查是否已安装依赖
if [ ! -d "node_modules" ]; then
    echo "正在安装依赖包..."
    npm install
    if [ $? -ne 0 ]; then
        echo "错误: 依赖安装失败"
        exit 1
    fi
fi

# 创建uploads目录
if [ ! -d "uploads" ]; then
    mkdir uploads
    echo "已创建uploads目录"
fi

# 启动服务器
echo "启动服务器中..."
echo
echo "========================================"
echo "电子礼金SaaS系统已启动"
echo "========================================"
echo "H5应用: http://localhost:3000"
echo "管理后台: http://localhost:3000/admin.html"
echo "互动大屏: http://localhost:3000/screen.html"
echo "========================================"
echo
echo "按 Ctrl+C 停止服务器"
echo

node server.js
